<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class jurusan_model extends CI_model {
    
    function __construct() {
        parent::__construct();
        $this->load->database();
    }
    
    public function insert_jurusan($fakultas_id, $nama, $alamat, $telp, $fax, $email, $website){
        $data = array(
            'FAKULTAS_ID'=>$fakultas_id,
            'JURUSAN_NAMA'=>$nama,
            'JURUSAN_ALAMAT'=>$alamat,
            'JURUSAN_TELP'=>$telp,
            'JURUSAN_FAX'=>$fax,
            'JURUSAN_EMAIL'=>$email,
            'JURUSAN_WEBSITE'=>$website,
        );
         $this->db->insert('jurusan', $data);   
    }
    public function get_jurusan()
    {
        $query = $this->db->get('JURUSAN');
        return $query;
    }
    
    public function get_jurusan_byid($jurusan_id)
    {
        $this->db->where('JURUSAN_ID', $jurusan_id);
        $query = $this->db->get('JURUSAN');
        return $query;
    }
    
    public function get_jurusan_fakultas()
    {
        $query = "SELECT * FROM fakultas f, jurusan j WHERE j.fakultas_id = f.fakultas_id";
        return $this->db->query($query);
    }
    
    public function get_jurusan_fakultas_byid($jurusan_id)
    {
        $query = "SELECT * FROM fakultas f, jurusan j WHERE j.fakultas_id = f.fakultas_id and j.jurusan_id =$jurusan_id";
        return $this->db->query($query);
    }
    
    public function del_jurusan($jurusan_id){
        $this->db->where('JURUSAN_ID', $jurusan_id);
        $this->db->delete('JURUSAN');
    }
}